/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef DESKTOPITEMHELPER_H
#define DESKTOPITEMHELPER_H

#include "types.h"

class DesktopItemHelper
{
public:
    DesktopItemHelper();

    static UKUI::CategoryIntList matchingAppCategories(QString category);
    static UKUI::ItemId calculateIdForNewItem(const QList<UKUI::ItemId> &oldIds);
    static UKUI::BaseItem *dissectInstalledDesktopFileToItem(const QString &desktopFile,
                                                  const UKUI::CategoryStringMap &categoryMap,
                                                  const QList<UKUI::ItemId> &existedIds);
    static UKUI::BaseItem *dissectInstallingDesktopFileToItem(const QString &desktopFile,
                                                  const UKUI::CategoryStringMap &categoryMap,
                                                  const QList<UKUI::ItemId> &existedIds);
    static UKUI::ItemId appIdByDesktopFromAllItems(const QString &desktopFile, const UKUI::ItemMap &allItems);
    static UKUI::ItemId appIdByNameFromAllItems(const QString &name, const UKUI::ItemMap &allItems);
    static QList<UKUI::ItemId> appIdsByDesktopFromAllItems(const QStringList &desktopFiles, const UKUI::ItemMap &allItems);

    static bool itemExistsInSet(UKUI::ItemId itemId, const UKUI::ItemIdInSetMap &itemIdsInSet);
    // exist, setId, pageIndex
    static std::tuple<bool, UKUI::ItemId, int> itemPositionInSet(int itemId,
                                                                 const UKUI::ItemIdInSetMap &itemIdsInSet);

};

#endif // DESKTOPITEMHELPER_H
